package com.ztz.mynewdemo.bean;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

/**
 * Created by wqewqe on 2017/5/22.
 */

public class MyDatabaseHelper extends SQLiteOpenHelper {
    Context context;
    public static final String CREATE_COLLECTION="create table Collection("
            +"id integer primary key autoincrement,"
            +"type integer,"
            +"title text,"
            +"date text,"
            +"category text,"
            +"author_name text,"
            +"url text,"
            +"image text)";
    public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
        this.context=context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_COLLECTION);
        Toast.makeText(context, "创建成功", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if exists Collection");
        onCreate(db);
    }
}
